<!DOCTYPE html>
<%@page import="utils.Utility"%>
<%@page import="domain.bw.BodyWeightOpen"%>
<%@page import="domain.bw.BodyWeight"%>
<%
	String userName = "";
	if (request.getSession().getAttribute("name") != null) {
		userName = request.getSession().getAttribute("name").toString();
	}
	if (!userName.equals("")) {
		String fileNo = (String) session.getAttribute("fileNo");
	String[] lactation = {"", "Lactation 1", "Lactation 2+"};
	
	BodyWeightOpen bw = (BodyWeightOpen) request.getAttribute("bw");
%>
<html lang="en">
<head>
<title>Set Values</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta name="description" content="">
<meta name="author" content="">

<!-- Le styles -->
<link href="../css/bootstrap.css" rel="stylesheet">
<!--    <link href="../css/bootstrap-responsive.css" rel="stylesheet">-->
<link href="../css/docs.css" rel="stylesheet">
<link href="../css/google-code-prettify/prettify.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->




<style type="text/css">
body {
	padding-top: 60px;
	padding-bottom: 40px;
}
</style>

</head>

<body onLoad="displayBW(1); displayBW(2)">

	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<a class="btn btn-navbar" data-toggle="collapse"
					data-target=".nav-collapse"> <span class="icon-bar"></span> <span
					class="icon-bar"></span> <span class="icon-bar"></span>
				</a> <a class="brand" href="#">DairyVIP Project</a>
				<div class="nav-collapse collapse">
					<p class="navbar-text pull-right">
						Logged in as <a href="#" class="navbar-link"><%=userName%></a>
					</p>
					<ul class="nav">
						<li><a href="../jsp/index.jsp">Home</a></li>
						<li><a href="../jsp/acknowledgements_contro.jsp">Acknowledgements/Contributors</a></li>
						<li><a href='../jsp/dataset.jsp'>My DairyVIP</a></li>
					</ul>
				</div>
			</div>
		</div>
	</div>



	<div class="container-fluid">
		<div class="container">
			<div class="pagination ">
				<ul>
					<li><a href="../jsp/inputMisc">Misc</a></li>
					<li><a href="../jsp/inputPrice">Price</a></li>
					<li><a href="../jsp/inputMilk">Milk</a></li>
					<li><a href="../jsp/inputCull">Cull</a></li>
					<li><a href="../jsp/inputRepro">Repro</a></li>
					<li class="active"><a href="#">Bodyweight</a></li>
				</ul>
			</div>
		</div>


		<div class="container">
			<legend>
				<small>BODY WEIGHT</small>
			</legend>
			<form id="saveBW" name="saveBW" method="post">
			
			<input class="btn" type="button" onclick="save(this.form)" value="Save" />
     		<input class="btn" type="button" onclick="saveAnalyze(this.form)" value="Save and Analyze" /><p></p>
			
			<% for(int lact=1; lact<=2; lact++) { %>
			
				<div class="span3">
					<table cellspacing="0" cellpadding="1" width="80%"
						style="font-size: 12px">
						<tr>
							<td style="background-color: #f5f5f5; border: solid 1px #ccc">
								<table width="100%">
									<tr>
										<td colspan="3" style="border: #CCC solid 1px;">
											<b><%= lactation[lact] %></b>
										</td>
									</tr>
									<tr>
										<td width="35%">+/- (abs)</td>
										<td width="35%"><input class="span1"
											style="width: 30px; height: 15px; font-size: 90%; padding: 2px; margin: 0px;"
											value=<%= Utility.roundUptoTwo(bw.getAbsAdjustment()[lact]) %> id="bwAbs<%= lact %>" size="4" type="text" name="bwAbs<%= lact %>"
											onChange="displayBW(<%= lact %>)"></td>
										<td></td>
									</tr>
									<tr>
										<td width="35%">+/- (%)</td>
										<td><input class="span1"
											style="width: 30px; height: 15px; font-size: 90%; padding: 2px; margin: 0px; display: inline"
											value=<%= Utility.roundUptoTwo(bw.getPctAdjustment()[lact] * 100) %> id="bwPct<%= lact %>" size="4" type="text" name="bwPct<%= lact %>"
											onChange="displayBW(<%= lact %>)">%</td>
										<td></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td></td>
						</tr>
						<tr>
							<td style="background-color: #f5f5f5; border: solid 1px #ccc">
								<table width="100%" id="lactation1">
									<tr>
										<td width="25%" align="center">Month</td>
										<td width="35%" align="center">&nbsp;</td>
										<td width="40%" align="center">Final Value</td>
									</tr>

									<% for (int mim = 1; mim <= 24; mim++) { %>
									<tr>
										<td width="25%" align="center"><%=mim%></td>
										<td width="35%" align="center"><input type="text"
											onChange="displayBW(<%= lact %>)" class="span1" name="bw<%= lact %>_<%= mim %>" id="bw<%= lact %>_<%= mim %>"
											style="width: 30px; height: 15px; font-size: 90%; padding: 2px; margin: 0px"
											value=<%= Utility.roundToZero(bw.getBodyWeightOpen()[lact][mim]) %>></td>
										<td width="40%" align="center"><span id="bwoutput<%= lact %>_<%=mim%>"></span></td>
									</tr>
									<% } %>
								</table>
							</td>
						</tr>
					</table>
					<p>&nbsp;</p>
					<!--<input class="btn" type="button" onclick="displayReproResults(); " value="Go" /> <br> <p>Please click this "Go" button. The computing results will be shown in the right table.</p><br>-->
				</div>

			<% } %>

			</form>
		</div>

		<p>&nbsp;</p>
		<footer class="footer">
			<%@ include file="../inc/footer.html"%>
		</footer>
		<!-- Le javascript
    ================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->



	<script language="javascript">
		function save(form)/*function to check userid & password*/
		{
			form.action = '../jsp/saveBW';
			form.submit();
			return true;
		}
		function saveAnalyze(form)/*function to check userid & password*/
		{
			form.action = '../jsp/saveAnalyzeBW';
			form.submit();
			return true;
		}
	</script>
	
	
		<script type="text/javascript" src="../js/jquery.js"></script>
		<script src="../js/bootstrap.js"></script>

		<script src="../js/computing.js"></script>
</body>
</html>
<%}else
out.print("Please <a href='../jsp/login.jsp'>log in</a> first!");
%>